<template>
    <el-button type="primary" @click="handleLogin">Login</el-button>
    <el-form ref="formRef"></el-form>
</template>
<script setup lang="ts">
import { useUserStore } from '@/store/user/index';
import { LoginRequest } from '@/api/user/types';
import { ElForm } from 'element-plus';
import { useComponentRef } from '@/hooks/useComponentRef';
const router = useRouter();
const userStore = useUserStore();
const userInfo = ref<LoginRequest>({
    username: 'admin',
    password: 'admin',
});
// const rules = ref({
//     username: [{ required: true, message: '请输入用户名', trigger: 'blur' }],
//     password: [{ required: true, message: '请输入密码', trigger: 'blur' }],
// });
const formRef = useComponentRef<typeof ElForm>();
function handleLogin() {
    userStore
        .storeUserLogin(userInfo.value)
        .then((res) => {
            router.push('/');
        })
        .catch((err: Error) => console.log(err));
}
</script>
<style lang="less" scoped></style>
